import http from '@/utils/http'

const BASE_URL = '/education/parent'

export interface ParentListQuery {
  keyword?: string
  status?: string | number
}

export interface ChildrenType {
  id: string
  name: string
  parentId: string
}

export interface ParentResp {
  id: string
  name: string
  mobilePhone: string
  recommender?: string
  username: string
  status: number
  remark?: string
  createTime: string
  lastLoginTime?: string
}

// 家长信息
export interface ParentDetailResp extends ParentResp {
  // studentList: Student[]
}

export const getParentPage = (query: ParentListQuery & PageQuery) => {
  return http.get<Page<ParentResp[]>>(`${BASE_URL}/page`, query)
}

export const getParentDetail = (id: string) => {
  return http.get<ParentDetailResp>(`${BASE_URL}/detail/${id}`)
}

/** @desc 修改家长 */
export function updateParent(data: any, id: string) {
  return http.post(`${BASE_URL}/update/${id}`, data)
}

export function updateRecommender(req: any) {
  return http.post(`${BASE_URL}/set-recommender/`, req)
}
